<script>
  if (window.opener)
    window.opener.postMessage({result: 'success'}, '*');
  else
    top.postMessage({result: 'success'}, '*');
</script>